package com.autonavi.yunda.yunji.core.enums;

import com.google.common.collect.Sets;
import lombok.Getter;

import java.util.Set;

public enum NodeStatus {

    INIT("初始"),
    RUNNING("运行中"),
    SUCCESS("运行成功"),
    INACCESSIBLE("不可达"),
    FAIL("运行失败"),
    CONDITION_FAIL("条件运行失败"),
    ;
    @Getter
    private final String desc;

    NodeStatus(String desc) {
        this.desc = desc;
    }

    public static final Set<NodeStatus> FINISHED_STATUS = Sets.newHashSet(SUCCESS, FAIL, INACCESSIBLE, CONDITION_FAIL);

    public boolean isFinishedStatus() {
        return FINISHED_STATUS.contains(this);
    }

    /**
     * 是否为失败异常节点
     */

    public boolean isFail() {
        return FAIL.equals(this) || CONDITION_FAIL.equals(this);
    }

    /**
     * 是否为不可达
     */
    public boolean isInaccessible() {
        return INACCESSIBLE.equals(this);
    }

    public boolean isRunning() {
        return RUNNING.equals(this);
    }

}